package com.nciae.handler;

import com.nciae.exception.PasswordException;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;

@Configuration
public class GlobeExceptionHandler {

    /**
     * 处理用户密码错误
     */
    @ControllerAdvice
    class PasswordExceptionHandler {

        @ResponseBody
        @ExceptionHandler(PasswordException.class)
        public ResponseEntity<String> passwordException(HttpServletResponse response, Exception e) {
            return ResponseEntity.ok("密码错误，请输入正确的用户密码");
        }
    }



}